import org.apache.activemq.command.ActiveMQDestination;

import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
import java.time.LocalTime;

public class QueueListener implements MessageListener {

    @Override
    public void onMessage(Message message) {
        try {
            if (message!=null) {
                ActiveMQDestination dest=(ActiveMQDestination)message.getJMSDestination();
                System.out.println("[" + dest.getPhysicalName() + "]received："+ ((TextMessage) message).getText()+"---"+ LocalTime.now());
                message.acknowledge();
            }
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}
